package gui;

import java.awt.Dimension;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.tree.TreePath;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ReisplanLocatiesOverzichtPanel extends javax.swing.JPanel {
	
	private TreePath[] locaties;
	private int yposition = -20;
	private Map<String, JLabel> labels;
	private Map<String, JTextField> textfields;
	
	public ReisplanLocatiesOverzichtPanel(TreePath[] locaties) {
		super();
		this.locaties = locaties;
		this.labels = new HashMap<String, JLabel>();
		this.textfields = new HashMap<String, JTextField>();
		initGUI();
	}
	
	private void initGUI() {
		try {
			this.setLayout(null);

			for (TreePath locatie : locaties) {
				yposition += 30;
				
				labels.put(locatie.getPathComponent(3).toString(), new JLabel());
				this.add(labels.get(locatie.getPathComponent(3).toString()));
				labels.get(locatie.getPathComponent(3).toString()).setBounds(20, yposition, 200, 24);
				labels.get(locatie.getPathComponent(3).toString()).setText(locatie.getPathComponent(3).toString());
				labels.get(locatie.getPathComponent(3).toString()).setForeground(new java.awt.Color(255,255,255));
				
				textfields.put(locatie.getPathComponent(3).toString(), new JTextField());
				this.add(textfields.get(locatie.getPathComponent(3).toString()));
				textfields.get(locatie.getPathComponent(3).toString()).setBounds(470, yposition, 80, 24);
				textfields.get(locatie.getPathComponent(3).toString()).setHorizontalAlignment(SwingConstants.CENTER);
			}
			
			this.setPreferredSize(new Dimension(550, yposition+35));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public Map<String, String> getLocatiesEnDagen() {
		Map<String, String> result = new HashMap<String, String>();
		
		for(Map.Entry<String, JLabel> entry : labels.entrySet()) {
			result.put(entry.getKey(), textfields.get(entry.getKey()).getText());
		}
		
		return result;
	}

}
